home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Atlanta_1990 / Atlanta-Devcon.1 / Libraries / Commodities / MBA / app.c next >
Encoding:
C/C++ Source or Header  |  1992-08-26  |  4.0 KB  |  160 lines

  1.  
  2.    /***********************************************************************
  3.    *                                                                      *
  4.    *                            COPYRIGHTS                                *
  5.    *                                                                      *
  6.    *   Copyright (c) 1990  Commodore-Amiga, Inc.  All Rights Reserved.    *
  7.    *                                                                      *
  8.    ***********************************************************************/
  9.  
  10. /* app.c This file contains the app code for a commodity */
  11. /* you should be able to write a new commodity by changing only */
  12. /* app.c and app.h */
  13.  
  14. #include "app.h"
  15.  
  16. #if WINDOW
  17.  
  18. #define V(x) ((VOID *)x)
  19.  
  20. struct TextAttr mydesiredfont =
  21.    {
  22.       "topaz.font",  /*  Name */
  23.       8,             /*  YSize */
  24.       0,             /*  Style */
  25.       0,             /*  Flags */
  26.    };
  27.  
  28. VOID setupCustomGadgets(gad)
  29. struct Gadget **gad;
  30. {
  31.    struct NewGadget ng;
  32.  
  33.    ng.ng_TopEdge    = topborder+0;
  34.    ng.ng_LeftEdge   = 10;
  35.    ng.ng_Width      = 40;
  36.    ng.ng_Height     = 12;
  37.    ng.ng_GadgetText = "Hide";
  38.    ng.ng_TextAttr   = &mydesiredfont;
  39.    ng.ng_GadgetID   = GAD_HIDE;
  40.    ng.ng_Flags      = NULL;
  41.    ng.ng_VisualInfo = vi;
  42.    *gad = CreateButtonGadget(*gad, &ng,TAG_DONE);
  43.  
  44.    ng.ng_TopEdge    = topborder+15;
  45.    ng.ng_LeftEdge   = 10;
  46.    ng.ng_Width      = 40;
  47.    ng.ng_Height     = 12;
  48.    ng.ng_GadgetText = "Die";
  49.    ng.ng_TextAttr   = &mydesiredfont;
  50.    ng.ng_GadgetID   = GAD_DIE;
  51.    ng.ng_Flags      = NULL;
  52.    ng.ng_VisualInfo = vi;
  53.    *gad = CreateButtonGadget(*gad, &ng,TAG_DONE);
  54. }
  55. VOID HandleGadget(gad,code)
  56. ULONG gad,code;
  57. {
  58.    D( kprintf("app: HandleGadget(%lx)\n",gad); )
  59.    switch(gad)
  60.    {
  61.       case GAD_HIDE:
  62.             D( kprintf("app: HandleGadget() GAD_HIDE\n"); )
  63.             shutdownWindow();
  64.             break;
  65.       case GAD_DIE:
  66.             D( kprintf("app: HandleGadget() GAD_DIE\n"); )
  67.             terminate();
  68.    }
  69. }
  70. VOID setupCustomMenu()
  71. {
  72.    struct NewMenu mynewmenu [] =
  73.       {
  74.          {  NM_TITLE,   "Project",  0,    0, 0, 0,             },
  75.          {   NM_ITEM,   "Hide",     "H",  0, 0, V(MENU_HIDE),   },
  76.          {   NM_ITEM,   "Die",      "Q",  0, 0, V(MENU_DIE),    },
  77.          {  NM_END,     0,          0,    0, 0, 0              },
  78.       };
  79.  
  80.    menu=CreateMenus(mynewmenu,TAG_DONE);
  81.    D( kprintf("app: CreateMenus returns menu =  %lx\n",menu); )
  82. }
  83. VOID handleCustomMenu(code)
  84. UWORD code;
  85. {
  86.    struct MenuItem *item;
  87.    BOOL terminated=FALSE;
  88.  
  89.    D( kprintf("app: handleCustomMenu(code=%lx)\n",code); )
  90.    while((code!=MENUNULL)&&(!terminated))
  91.    {
  92.       item=ItemAddress(menu,code);
  93.       switch((int)MENU_USERDATA(item))
  94.       {
  95.          case MENU_HIDE:
  96.                shutdownWindow();
  97.                terminated=TRUE; /* since window is gone NextSelect is invalid so...*/
  98.                break;
  99.          case MENU_DIE:
  100.                terminate();
  101.                break;
  102.          default:
  103.                break;
  104.       }
  105.       code=item->NextSelect;
  106.       D( kprintf("app: handleCustomMenu next code=%lx\n",code); )
  107.    }
  108.    D( kprintf("app: handleCustomMenu exits"); )
  109. }
  110. VOID refreshWindow()
  111. {
  112.    if(window)
  113.    {
  114.       if(IDCMPRefresh)
  115.          GT_EndRefresh( window, 1L );
  116.  
  117.       SetAPen(window->RPort,1);
  118.       SetBPen(window->RPort,2);
  119.       SetDrMd(window->RPort,JAM2);
  120.       SetFont(window->RPort,font);
  121.       Move(window->RPort,50,topborder+40);
  122.       Text(window->RPort,"Your Imagery Here",17);
  123.  
  124.       if(IDCMPRefresh)
  125.          GT_EndRefresh( window, 1L );
  126.  
  127.       /* It is possible that the user has selected a font so large */
  128.       /* that our imagery will fall off the bottom of the window   */
  129.       /* we RefreshWindowFrame here incase our borders were overwritten */
  130.       if((topborder+WINDOW_INNERHEIGHT) > window->Height)
  131.          RefreshWindowFrame(window);
  132.    }
  133.    return;
  134. }
  135.  
  136. #endif /* WINDOW */
  137.  
  138. BOOL setupCustomCX()
  139. {
  140.    return(setupMBA());
  141. }
  142. VOID shutdownCustomCX()
  143. {
  144. }
  145. VOID handleCustomCXMsg(id)
  146. ULONG id;
  147. {
  148.    switch(id)
  149.    {
  150.       case 0:
  151.       default:
  152.             break;
  153.    }
  154. }
  155. #if CSIGNAL
  156. VOID handleCustomSignal(VOID)
  157. {
  158. }
  159. #endif
  160.